#!/usr/bin/env python

def usage():
	print "takes no parameters adds lines at end of files"

from sys import argv
import os

if len(argv) > 1:
	usage()
else:
	files = os.listdir(".")
	count=0
	nb_changed=0
	changed_files=[]
	for a in files:
		if a.endswith(".c") or a.endswith(".h"):
			count +=1
			fp = open(a,"r+")
			if fp:
				last_line = fp.readlines()[-1].replace(" ","")
				if last_line != "\n":
					fp.seek(0,2)
					fp.write('\n')
					fp.close()
					nb_changed +=1
					changed_files.append(a)
	if nb_changed > 0:
		chg_txt = " : "+", ".join(changed_files)
	else:
		chg_txt = "."
	print count,"files analyzed,",nb_changed,"changed"+chg_txt